# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgname=udisks2
pkgver=2.10.1
pkgrel=2
pkgdesc="Daemon, tools and libraries to access and manipulate disks, storage devices and technologies"
arch=('loong64' 'x86_64')
url="https://www.freedesktop.org/wiki/Software/udisks/"
license=(
  GPL-2.0-or-later
  LGPL-2.0-or-later
)
depends=(
  'acl'
  'btrfs-progs'
  'gcc-libs'
  'glib2'
  'glibc'
  'libatasmart'
  'libblockdev'
  'libgudev'
  'lvm2'
  'polkit'
  'systemd-libs'
  'util-linux-libs'
)
makedepends=(
  'gobject-introspection'
  'gtk-doc'
)
optdepends=(
  'dosfstools: FAT filesystem support'
  'exfatprogs: exFAT filesystem support'
  'e2fsprogs: Ext2/3/4 filesystem suport'
  'udftools: UDF filesystem support'
  'xfsprogs: XFS filesystem support'
)
backup=('etc/udisks2/udisks2.conf')
source=("https://github.com/storaged-project/udisks/releases/download/udisks-$pkgver/udisks-$pkgver.tar.bz2")
sha512sums=('9cdaeca4306a970c85f88d406dbe5d2dad23d72f47d9ab1c021b8c2888d4c790f680eb94388d86f9255024283b4a36e98b8aee4408d193a7d4aad1e74463356a')
b2sums=('41282e4dbbd93e6bda2a10a6ff2f2fb82bfc83b3ccbed9450cca7888c634cde9300fcd0b7d055e0d8e4c8fc0b431a75d5612a24132ea9b2677d194529732178d')

build() {
  local configure_options=(
    --disable-static
    --enable-btrfs
    --enable-gtk-doc
    --enable-lvm2
    --libexecdir=/usr/lib
    --localstatedir=/var
    --prefix=/usr
    --sbindir=/usr/bin
    --sysconfdir=/etc
    --with-systemdsystemunitdir=/usr/lib/systemd/system
  )

  cd udisks-$pkgver
  ./configure "${configure_options[@]}"
  # prevent libtool from overlinking everything
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd udisks-$pkgver
  make check
}

package() {
  cd udisks-$pkgver
  make DESTDIR="$pkgdir" install

  # interface declaration
  install -vDm 644 data/org.freedesktop.UDisks2.xml -t "$pkgdir/usr/share/dbus-1/interfaces/"
}
